import React from 'react';
import { getmyprocessjsonbydeploymentid } from '@/services/flowMine/apply';

export function useProcessList(formValueJson = {}, processDeploymentId = '') {
    const [data, setData] = React.useState([]);
    const [loading, setLoading] = React.useState(true);

    React.useEffect(() => {
        const fetchProcess = async () => {
            setLoading(true);
            const result = await getmyprocessjsonbydeploymentid(formValueJson, processDeploymentId);
            if (result.code === 10000) {
                setData(result.data);
            }
            setLoading(false);
        };
        fetchProcess();
    }, [formValueJson, processDeploymentId]);

    return [loading, data];
}

export function useAllowedLeaveList() {
    const [data, setData] = React.useState([]);
    const [loading, setLoading] = React.useState(true);

    React.useEffect(() => {
        const fetchProcess = async () => {
            setLoading(true);
            const result = await getmyprocessjsonbydeploymentid();
            if (result.code === 10000) {
                setData(result.data);
            }
            setLoading(false);
        };
        fetchProcess();
    }, []);

    return [loading, data];
}
